﻿
using commonlib;
using System.Configuration;
using System;
using System.Threading;
namespace commonlib
{
    public class ClientApp
    {
        static Client thisClient;

        public delegate void requestSystemUpdate();

        static void Main(string[] args)
        {
            if (args.Length > 2)
            {                
                thisClient = new Client(args[0], args[1], Convert.ToInt16(args[2]));
                thisClient.centralAdress = ConfigurationManager.AppSettings["central_directory_address"];
                thisClient.centralPort = Convert.ToInt16(ConfigurationManager.AppSettings["central_directory_port"]);
                thisClient.requestUpdateSystemTimeOut = Convert.ToInt16(ConfigurationManager.AppSettings["request_system_update_time_out"]);
                //  thisClient.initServices();
                thisClient.requestRegister();
                //  thisClient.beginTx("address","lisboa");  

                //atualizar o estado do sistema
                ClientApp.requestSystemUpdate systemUpdateDlgt = new ClientApp.requestSystemUpdate(thisClient.requestSystemUpdate);
                Thread thread1 = new Thread(new ThreadStart(systemUpdateDlgt));
                thread1.Start();

                Console.ReadKey();
            }
        }
    }
}

